<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>和谐投票</title></head>
<body>
<!--<div align="center">
	<form method="post" action="">
		<br><span>亲，想让我来帮你投几票啊？ </span><br><br><input type="text" name="num" value="10"/>
		<input type="submit" value="提交"/>
	</form>
	<a href="http://www.rwnest.com">静忘天空</a> 诚意出品 -- 2011
	</div>
-->
  <h2>和谐社会，文明投票...如有需要，程序将自动执行，无需手动输入...</h2>
  <h3><a href="http://www.rwnest.com">静忘天空</a> 诚意出品 -- 2011</h3>
</body>
</html>
<?php
	//@$num=$_POST['num'];
	include './snoopy/snoopy.class.php';

	try{
		$snoopy1 = new Snoopy();
		$snoopy2 = new Snoopy();
		$url="http://su.100steps.net/2007/vote/result.php?tid=91";
		$snoopy1->rawheaders["X_FORWARDED_FOR"] = "125.rand(215,220).".rand(0,255).".".rand(0,255);
		$snoopy2->rawheaders["X_FORWARDED_FOR"] = "125.rand(215,220).".rand(0,255).".".rand(0,255);
		$snoopy1->fetchlinks($url);
		$snoopy2->fetchtext($url);
		$i = 0;
		foreach($snoopy1->results as $k => $result){
			if($k&&$i<10){
				$pollid[$i] = $snoopy1->results[$k];
				$pollid[$i] = (int)substr($pollid[$i],-4);
				$i++;
			}
		}
		$page = mb_convert_encoding($snoopy2->results,"utf-8","gbk");
		preg_match_all('/\[([0-9]{1,6}).?票\]/U',$page,$pollnums);
		$pollnum = $pollnums[0];
		for($i=0;$i<10;$i++){
			$pollnum[$i] = (int)substr($pollnum[$i],1,-5);
			$list[$pollid[$i]] = $pollnum[$i];	
		}//echo $pollnum[1];
		if(($list[2562]-$pollnum[1])<50){
			$addnum = $pollnum[1]+50-$list[2562];
			poll($addnum) ;
		}
	}catch (Exception $e) {
		echo 'Caught exception: ',  $e->getMessage(), "\n";
	}

	function poll($num){
		$num = (int) $num;
		for($i=0;$i<$num;$i++){
			try{
				$snoopy = new Snoopy();
				$url="http://su.100steps.net/2007/vote/vote.php";
				$vars = array("tid"=>91,"vid"=>2562,"submit"=>"给我投上宝贵一票吧");
				$snoopy->rawheaders["X_FORWARDED_FOR"] = "125.rand(215,220).".rand(0,255).".".rand(0,255);
				$snoopy->submit($url, $vars);
				echo "已经投了".($i+1)."票！<br>";
			}catch (Exception $e) {
				echo 'Caught exception: ',  $e->getMessage(), "\n";
			}
		}
	}
?>
